using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Beta_fundies_controls_comments_EditCommentForm : Controls.DataManagerCommentControl
{
    protected override void ItemChanged()
    {
        if (CurrentComment != null)
        {
            mviewComment.SetActiveView(viewEdit);
            txtPost.Text = CurrentComment.Post;
            txtUsername.Text = CurrentComment.Author;
        }
        else
        {
            mviewComment.SetActiveView(viewError);
        }
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        CurrentComment.Visible = false;
        DAL.Comments.Save(CurrentComment);
        mviewComment.SetActiveView(viewDeleted);
        CurrentComment.Quote.TotalComments -= 1;
        DAL.Quotes.Save(CurrentComment.Quote);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            CurrentComment.Author = txtUsername.Text;
            CurrentComment.Post = txtPost.Text;
            DAL.Comments.Save(CurrentComment);
            mviewComment.SetActiveView(viewSaved);
            RefreshList();
        }
    }

    private void RefreshList()
    {
        List<DAL.Comment> myComment = new List<DAL.Comment>(1);
        myComment.Add(CurrentComment);
        Comments1.SetDataSource(myComment);
    }
}
